#include "treewidget.h"
#include <QTreeWidgetItem>

TreeWidget::TreeWidget(QWidget *parent)
    : QWidget(parent)
{
    tree = new QTreeWidget(this);
    tree->setColumnCount(2);

    QStringList headers;
    headers << "Name" << "Number";
    tree->setHeaderLabels(headers);

    QStringList rootTextList;
    rootTextList << "Root" << "0";


    QTreeWidgetItem *root = new QTreeWidgetItem(tree, rootTextList);

    QStringList leafTextList;
    leafTextList << "Leaf 1" << "1";
    QTreeWidgetItem *leaf = new QTreeWidgetItem(root, leafTextList);
    root->addChild(leaf);

    QStringList leaf2TextList;
    leaf2TextList << "Leaf 2" << "2";
    QTreeWidgetItem *leaf2 = new QTreeWidgetItem(root, leaf2TextList);
    leaf2->setCheckState(0, Qt::Checked);
    root->addChild(leaf2);

    QList<QTreeWidgetItem *> rootList;
    rootList << root;
    tree->insertTopLevelItems(0, rootList);

}

QSize TreeWidget::sizeHint() const
{
    return QSize(300, 400);
}

TreeWidget::~TreeWidget()
{

}
